package com.example.fill;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

public class V2413 extends View {

    private Paint paint = new Paint();
    private Canvas mCanvas;
    private Bitmap mBitmap;

    public V2413(Context context) {
        super(context);
    }

    public V2413(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public V2413(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public V2413(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        init();
    }

    private void init(){
        mBitmap = Bitmap.createBitmap(getMeasuredWidth(),getMeasuredHeight(),Bitmap.Config.ARGB_8888);
        mCanvas = new Canvas(mBitmap);
        paint.setColor(Color.RED);
        paint.setStyle(Paint.Style.FILL);
        mCanvas.drawRect(0,0,200,200,paint);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawBitmap(mBitmap,0,0,null);
    }
}
